package com.egao.orderB.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
import com.egao.orderB.biz.DriverMileageBiz;
import com.egao.orderB.entity.DriverMileage;
import com.egao.orderB.service.DriverMileageService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

//import com.egao.orderB.mapper.DriverMileageMapper;
//import javax.transaction.Transactional;

/**
 * 里程费用服务实现类
 * @author : Doman
 * @date : 2021-06-04 16:00:59
 * @version ：1.0
 */
@Service
public class DriverMileageServiceImpl /*extends ServiceImpl<DriverMileageMapper, DriverMileage> */implements DriverMileageService {

	@Autowired
	private DriverMileageBiz driverMileageBiz;

    /**
    @Override
    public PageResult<DriverMileage> listPage(PageParam<DriverMileage> page) {
        List<DriverMileage> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<DriverMileage> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */

    @Override
    public JsonResult list(PageResult2<T> page, DriverMileage driverMileage, User loginUser)  throws Exception{
        return driverMileageBiz.list(page,driverMileage,loginUser);
    }

    @Override
    public JsonResult list(DriverMileage driverMileage, User loginUser) {
        return JsonResult.ok().setData(driverMileageBiz.list(driverMileage,loginUser));
    }

    @Override
    public JsonResult getById(DriverMileage driverMileage) {
        return JsonResult.ok().setData(driverMileageBiz.getById(driverMileage));
    }

    @Transactional
    @Override
    public JsonResult save(DriverMileage driverMileage, User loginUser) {
        if (driverMileageBiz.save(driverMileage, loginUser)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }

    @Transactional
    @Override
    public JsonResult update(DriverMileage driverMileage, User loginUser) {
        if (driverMileageBiz.update(driverMileage, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Transactional
    @Override
    public JsonResult remove(DriverMileage driverMileage, User loginUser) {
        if (driverMileageBiz.remove(driverMileage, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
